package com.zhentao.controller;

import com.github.pagehelper.PageInfo;
import com.zhentao.mapper.WithdrawRuleMapper;
import com.zhentao.model.common.dtos.ResponseResult;
import com.zhentao.model.pay.dto.PayDto;
import com.zhentao.model.pay.pojo.WithdrawRule;
import com.zhentao.model.pay.vo.FinancialVo;
import com.zhentao.service.WithdrawRuleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("api/v1/admin/pay/rule")
@Api(tags = "WithdrawRuleController-分红规则管理")
public class WithdrawRuleController {
    @Resource
    WithdrawRuleService withdrawRuleService;

    /**
     * 分红规则管理列表
     * @param dto
     * @return
     */
    @PostMapping("/list")
    @ApiOperation("分红规则管理列表")
    public ResponseResult list(@RequestBody PayDto dto){
        PageInfo<WithdrawRule> list =withdrawRuleService.getList(dto);
        return ResponseResult.okResult(list);
    }

    /**
     * 分红规则列表的添加
     * @param withdrawRule
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("分红规则列表的添加")
    public ResponseResult add(@RequestBody WithdrawRule withdrawRule){
        return withdrawRuleService.add(withdrawRule);
    }

    /**
     * 分红规则列表的修改
     * @param withdrawRule
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("分红规则列表的修改")
    public ResponseResult update(@RequestBody WithdrawRule withdrawRule){
        return withdrawRuleService.updateRule(withdrawRule);
    }

    /**
     * 分红规则列表的删除
     * @param id
     * @return
     */
    @PostMapping("/del")
    @ApiOperation("分红规则列表的删除")
    public ResponseResult del(@RequestParam("id") Integer id){
        withdrawRuleService.removeById(id);
        return ResponseResult.okResult("删除成功！");
    }
}
